/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mapreduce;

/**
 *
 * @author haoyun
 */

import fj.data.List;
import static fj.data.List.*;

public class Reliable {

    public static List<Integer> prob2num(List<Double> rel, List<Double> err){

        List<Integer> num=list();
        int n=1;
        int id=0;
        System.out.println("required_reliability, error_rate, required_redundancy");
        for (Object r: rel){

            double r1=(Double)r;
            double e1=(Double)err.index(id);
            if(r1>0 & e1>0){
                n=(int)Math.round(Math.log(1-r1)/Math.log(e1));
                if(n<Math.log(1-r1)/Math.log(e1))
                    n=n+1;
            }
            else
                n=1;
            if(n<1)
                n=1;
            num=num.snoc(n);
            System.out.println(r1+", "+e1+", "+n);
            id++;
        }
        return num;

    }

}
